local yicheng = fk.CreateSkill {
  name = "ls__yicheng",
}

Fk:loadTranslationTable{
  ["ls__yicheng"] = "疑城",
  [":ls__yicheng"] = "当一名角色使用【杀】或通常锦囊牌时，若使用者或目标角色包括你，"..
  "你可摸一张牌，令此牌效果改为【调虎离山】；然后当前回合角色可弃置一张与此牌颜色相同的牌，对所有目标角色各造成1点伤害。",
  ["#ls__yicheng-discard"] = "裂师：你可以弃置一张与%arg颜色相同的牌，对目标角色各造成1点伤害。",

  ["$ls__yicheng1"] = "今疑兵之计，以挫敌兵心胆，其安胆侵进。",
  ["$ls__yicheng2"] = "敌军色厉内荏，可筑假城以退敌。",
}

local DIY = require "packages/diy_utility/diy_utility"

yicheng:addEffect(fk.CardUsing, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(yicheng.name) and (data.card.trueName == "slash" or data.card:isCommonTrick()) then
      return target == player or (data.tos and table.contains(data.tos, player))
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:drawCards(1, yicheng.name)
    local tos = table.filter(data.tos, function (p) return not p.dead end)
    local current = room.current
    local cards = table.filter(current:getCardIds("he"), function (id)
      return Fk:getCardById(id):compareColorWith(data.card) and not current:prohibitDiscard(id)
    end)
    local card = room:askToDiscard(current, {
      min_num = 1,
      max_num = 1,
      include_equip = true,
      skill_name = yicheng.name,
      pattern = tostring(Exppattern{ id = cards }),
      prompt = "#ls__yicheng-discard:::"..data.card:toLogString(),
      cancelable = true,
    })
    if #card > 0 then
      for _, p in ipairs(tos) do
        if not p.dead then
          room:damage({
            from = current,
            to = p,
            damage = 1,
            skillName = yicheng.name,
          })
        end
      end
    end
    local use_card = data.card:clone()
    local c = table.simpleClone(data.card)
    for k, v in pairs(c) do
      use_card[k] = v
    end
    use_card.skill = Fk.skills["lvshi__lure_tiger_skill"]
    data.card = use_card
  end,
})

return yicheng